

package com.hazelcast.client.map.impl.iterator;

import com.hazelcast.client.impl.proxy.ClientMapProxy;

import javax.annotation.Nonnull;
import java.util.Iterator;
import java.util.Map;

/**
 * Client-side iterable that provides an iterator for iterating map
 * entries in the whole cluster.
 * It returns {@link ClientMapIterator}.
 *
 * @param <K> the key type of map.
 * @param <V> the value type of map.
 * @see ClientMapIterator
 */
public class ClientMapIterable<K, V> implements Iterable<Map.Entry<K, V>> {
    private final ClientMapProxy<K, V> clientMapProxy;
    private final int fetchSize;
    private final int partitionCount;
    private final boolean prefetchValues;

    public ClientMapIterable(ClientMapProxy<K, V> clientMapProxy, int fetchSize, int partitionCount, boolean prefetchValues) {
        this.clientMapProxy = clientMapProxy;
        this.partitionCount = partitionCount;
        this.fetchSize = fetchSize;
        this.prefetchValues = prefetchValues;
    }

    @Nonnull
    @Override
    public Iterator<Map.Entry<K, V>> iterator() {
        return new ClientMapIterator<>(clientMapProxy, fetchSize, partitionCount, prefetchValues);
    }
}
